Character encoding transformation - utilities
- Copyright (C) 2005 Olaf Klein, o.b.klein@gpsbabel.org
+ Copyright (C) 2005,2006,2007 Olaf Klein, o.b.klein@gpsbabel.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
{
waypoint *w = (waypoint *)wpt;
format_specific_data *fs;
+ url_link *url_next;
if ((cet_output == 0) && (w->wpt_flags.cet_converted != 0)) return;
w->notes = cet_convert_string(wpt->notes);
w->url = cet_convert_string(wpt->url);
w->url_link_text = cet_convert_string(wpt->url_link_text);
+ for (url_next = w->url_next; url_next; url_next = url_next->url_next) {
+ url_next->url = cet_convert_string(url_next->url);
+ url_next->url_link_text = cet_convert_string(url_next->url_link_text);
+ }
fs = wpt->fs;
while (fs != NULL)
#define FS_OZI 0x6f7a6900L
#define FS_GMSD 0x474d5344L /* GMSD = Garmin specific data */
+/*
+ * Structures and functions for multiple URLs per waypoint.
+ */
+typedef struct url_link {
+ struct url_link *url_next;
+ char *url;
+ char *url_link_text;
+} url_link;
+
/*
* Misc bitfields inside struct waypoint;
*/
typedef struct {
double max_lat;
double max_lon;
+ double max_alt;
double min_lat;
double min_lon;
+ double min_alt;
} bounds;
typedef struct {
int request_terminate;
} posn_status;
-/*
- * Structures and functions for multiple URLs per waypoint.
- */
-typedef struct url_link {
- struct url_link *url_next;
- char *url;
- char *url_link_text;
-} url_link;
-
-void add_url(waypoint *wpt, char *link, char *url_link_text);
-
typedef void (*ff_init) (char const *);
void waypt_flush_all(void);
unsigned int waypt_count(void);
void set_waypt_count(unsigned int nc);
+void waypt_add_url(waypoint *wpt, char *link, char *url_link_text);
void free_gpx_extras (xml_tag * tag);
void xcsv_setup_internal_style(const char *style_buf);
void xcsv_read_internal_style(const char *style_buf);
lt = xstrdup(lrtrim(link_text));
}
- add_url(wpt_tmp, xstrdup(link_url), lt);
+ waypt_add_url(wpt_tmp, xstrdup(link_url), lt);
link_text = NULL;
}
break;
* This and waypt_free should be closely synced.
*/
waypoint * tmp;
+ url_link *url_next;
+
tmp = waypt_new();
memcpy(tmp, wpt, sizeof(waypoint));
tmp->url = xstrdup(wpt->url);
if (wpt->url_link_text)
tmp->url_link_text = xstrdup(wpt->url_link_text);
+ for (url_next = wpt->url_next; url_next; url_next = url_next->url_next) {
+ waypt_add_url(tmp,
+ (url_next->url) ? xstrdup(url_next->url) : NULL,
+ (url_next->url_link_text) ? xstrdup(url_next->url_link_text) : NULL);
+ }
if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic)
tmp->icon_descr = xstrdup(wpt->icon_descr);
if (wpt->gc_data.desc_short.utfstring) {
bounds->max_lon = -9999;
bounds->min_lat = 9999;
bounds->min_lon = 9999;
+ bounds->max_alt = -unknown_alt;
+ bounds->min_alt = unknown_alt;
}
int
bounds->min_lat = waypointp->latitude;
if (waypointp->longitude < bounds->min_lon)
bounds->min_lon = waypointp->longitude;
+ if (waypointp->altitude != unknown_alt) {
+ if (waypointp->altitude < bounds->min_alt)
+ bounds->min_alt = waypointp->altitude;
+ if (waypointp->altitude > bounds->max_alt)
+ bounds->max_alt = waypointp->altitude;
+ }
}
waypt_ct = count;
xfree(head_bak);
}
+
+void
+waypt_add_url(waypoint *wpt, char *link, char *url_link_text)
+{
+ if ((link == NULL) && (url_link_text == NULL)) return;
+
+ /* Special case first one; it goes right into the waypoint. */
+ if ((wpt->url == NULL) && (wpt->url_link_text == NULL)) {
+ wpt->url = link;
+ wpt->url_link_text = url_link_text;
+ } else {
+ url_link *tail;
+ url_link *new_link = xcalloc(sizeof(url_link), 1);
+ new_link->url = link;
+ new_link->url_link_text = url_link_text;
+
+ /* Find current end of chain and tack this onto the end.. */
+ for (tail = wpt->url_next;;tail = tail->url_next) {
+ if (tail == NULL) {
+ wpt->url_next = new_link;
+ break;
+ }
+ if (tail->url_next == NULL) {
+ tail->url_next = new_link;
+ break;
+ }
+ }
+ }
+}